﻿window.onload=function(){
	window.setInterval("dealAllCookie()",500);
}

//IP地址
var subsystem_url = "http://59.108.92.239/amucsite/web";
var sso_url = "http://59.108.92.239:9081";
var url_code = "yxweb";

//弹出窗口位置
var iWidth=976; //弹出窗口的宽度;
var iHeight=635; //弹出窗口的高度;
var iTop = (window.screen.availHeight-iHeight)/2; //获得窗口的垂直位置;
var iLeft = (window.screen.availWidth-iWidth)/2; //获得窗口的水平位置;
var window_site = "height=635, width=976,top="+iTop+",left="+iLeft+", toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no";
 
 //判断处理cookie   
function dealAllCookie(){
	//如果cookie中同时不包含这些，说明cookie中无用户信息，没登录
	if(doGetCookie("username_fouNder")==undefined || doGetCookie("username_fouNder")=="" || doGetCookie("username_fouNder") == null){     
	   $("#sso-active").show();
	   $("#sso-inactive").hide();
	}else{
		var cookieValue=doGetCookie("username_fouNder");
		$("#sso-active").hide();
		$("#sso-inactive").show();
		$("#uname").text(cookieValue);
	}
}
 
var onClose = function () {
	$(".k-window").remove();
	$(".user-bar").append('<div id="window"></div>');
}
function openWindow(title,url,width,height){
	var myWindow = $("#window");
	myWindow.kendoWindow({
		width: width+"px",
		height: height+"px",
		title: title,
		content: url,
		reverse: true,
		visible: false,
		close: onClose,
		modal: true
	}).data("kendoWindow").center().open(); 
}
 //登录
function ssologin(){
  //window.open (sso_url+"/SSOv2/user/ssoLogin?code=jjrb&redirectUrl="+login_out+"/dsp/scripts/sso/setCookie.html?","newwindow", window_site);     
	var url = sso_url+"/SSOv2/user/ssoLogin?code=" + url_code + "&redirectUrl="+subsystem_url+"/sso/setCookie.html?";
	openWindow("",url,"450","490");  
} 

// 移动端登录
function mobile_ssologin(){
	// 首先获取页面来源地址
	var original_URL = window.location.href;
	var url = sso_url+"/SSOv2/user/ssoLogin?code=jjrb&redirectUrl="+subsystem_url+"/dsp/scripts/sso/setCookie.html?&isAppType=app&jjrbUrl="+original_URL;
	window.location.href = url ;
}
 
//注册
function register(){
//	window.open (sso_url+"/SSOv2/user/register","newwindow", window_site);     
	var url = sso_url+"/SSOv2/user/register";
	//var url = "http://59.108.92.239:9081/SSOv2/user/login";
	openWindow("",url,"450","490");	
} 

//退出。设置好的 cookie会自动失效，只需设置效果即可   
function exit() {
	//window.open(sso_url+"/SSOv2/user/ssoLogout?code=jjrb&from="+login_out+"/dsp/scripts/sso/delCookie.html","newwindow", window_site);   
	var url = sso_url+"/SSOv2/user/ssoLogout?code=" + url_code + "&from="+subsystem_url+"/sso/delCookie.html";
	openWindow("",url,"500","470");
} 
//   移动端退出。设置好的 cookie会自动失效，只需设置效果即可   
function mobile_exit() {
	var url = "http://59.108.92.239:9081/SSOv2/user/login_app";
	//var url = sso_url+"/SSOv2/user/ssoLogout?code=jjrb&from="+login_out+"/dsp/scripts/sso/delCookie.html&isAppType=app";
	window.location.href = url ;
} 
